'use strict';

const Controller = require('egg').Controller;

const { handleTree } = require('./tools')

class MenuController extends Controller {
  async lists() {
    const { ctx } = this;
    const result = await ctx.model.Menus.findAndCountAll();
    if(!result) {
      ctx.throw(500,'获取错误')
    }else{
      ctx.returnBody(handleTree(result.rows),100010)
    }

  }
}

module.exports = MenuController;